package com.zrf.action;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.zrf.service.LoginService;




@RequestMapping("/la")
@Controller
public class LoginAction {

	
	@Autowired
	private LoginService ls = null;
	
	@RequestMapping(value="buyerlogin",params={"name","password"})
	public String buyerlogin(@RequestParam("name") String name,@RequestParam("password") String password,Map<String,Object> map){
		try {
			if(ls.login(1, name, password)){
				return "product";
			}
		} catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		}
		
		return "fail";
	}
	
	
	@RequestMapping(value="sellerlogin",params={"name","password"})
	public String sellerlogin(@RequestParam("name") String name,@RequestParam("password") String password,Map<String,Object> map){
		try {
			if(ls.login(2, name, password)){
				return "shop";
			}
		} catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		}
		
		
		
		return "fail";
	}
}
